home *** CD-ROM | disk | FTP | other *** search
- Path: lyra.csx.cam.ac.uk!lhkc100
- From: lhkc100@thor.cam.ac.uk (L.H.K. Chan)
- Newsgroups: comp.lang.c++
- Subject: Re: How to read: operator overloaded <<
- Date: 21 Apr 1996 14:33:27 GMT
- Organization: University of Cambridge, England
- Message-ID: <4ldgvn$skv@lyra.csx.cam.ac.uk>
- References: <4ldfpc$j0u@amanda.dorsai.org>
- NNTP-Posting-Host: hammer.thor.cam.ac.uk
-
- In article <4ldfpc$j0u@amanda.dorsai.org>, mongoose@dorsai.org (Jeff Yu) writes:
- |> Hi, I have hard time to understand the syntac of << operator overloaded
- |> declaration. As it is stated in Lippman's C++ Primer, the << sample is
- |> supposed to take TWO parameters: ostream& operator<<(ostream& os, String& s)
- |> But when using it, the way is: cout<<"test"<<MyScreen<<endl;
- |> Where is the second parameter if I consider the MyScreen as the first one?
-
- Think about it in this way,
-
- << ( << ( << (cout, "test"), MyScreen), endl);
-
- That is, instead of thinking it as an infix operator, think about it as prefix
- operator! Is that clear?
-
- Regards,
-
- Kelvin
-
- |>
- |> What is the difference from ostream& operator << (String &s)?
- |>
- |> Please help!
- |>
-